/**
 * Created by rabbibox on 2017/1/3.
 */


var bx = function(){};
bx.prototype = {
  getId:function(){
    if($('input.grid:checked').size() > 1){
      return -1;
    }else{
      var n = $('input.grid:checked').val();
      if(n === undefined){
        return 0;
      }else{
        return n;
      }
    }
  },
  getIds:function(){
    //var n = $('input.grid:checked').val();
    var ids = [];
    $("input.grid:checked").each(function () {
      ids.push($(this).val());
    });
    return ids;
  },
  getParamIds:function(){
    var s = '';
    $("input.grid:checked").each(function () {
      s += 'id[]='+$(this).val()+"&";
    });
    return s;
  },
  layer:function(url,title){
    var index = layer.open({
      type: 2,
      title: title,
      //shadeClose: true,
      //shade: false,
      //maxmin: true, //开启最大化最小化按钮
      //area: ['80%', '100%'],
      content: url
    });
    layer.full(index);
  },
  comAjax:function(url, params, callback){
    url = '/index.php?r=admin/'+ url;
    params = params || {};
    callback = callback || function(){};
    result = false;
    $.ajax({
      type : 'POST',
      url : url,
      data : params,
      datatype : "json",
      success : function(data) {
        callback(data);
      }
    });
  },
  toUrl:function(url,param){
    s = (url.indexOf("?")!=-1)?'&':'?';
    return  url + s + param;
  }

};
var $bx = new bx();
